package com.tencent.mid.a;

import org.apache.http.HeaderElement;
import org.apache.http.HeaderElementIterator;
import org.apache.http.HttpResponse;
import org.apache.http.conn.ConnectionKeepAliveStrategy;
import org.apache.http.message.BasicHeaderElementIterator;
import org.apache.http.protocol.HttpContext;

final class c
  implements ConnectionKeepAliveStrategy
{
  public final long getKeepAliveDuration(HttpResponse paramHttpResponse, HttpContext paramHttpContext)
  {
    long l1 = 10L;
    if (paramHttpResponse == null)
      throw new IllegalArgumentException("HTTP response may not be null");
    paramHttpResponse = new BasicHeaderElementIterator(paramHttpResponse.headerIterator("Keep-Alive"));
    while (true)
    {
      Object localObject;
      if (paramHttpResponse.hasNext())
      {
        localObject = paramHttpResponse.nextElement();
        paramHttpContext = ((HeaderElement)localObject).getName();
        localObject = ((HeaderElement)localObject).getValue();
        if ((localObject == null) || (!(paramHttpContext.equalsIgnoreCase("timeout"))))
          continue;
      }
      try
      {
        long l2 = Long.parseLong((String)localObject);
        if (l2 > 11L)
          l1 = l2 - 10L;
        return (l1 * 1000L);
        return 180000L;
      }
      catch (java.lang.NumberFormatException paramHttpContext)
      {
      }
    }
  }
}